<?php
/**
 * 资讯类
 * @author zengnz
 *
 */
class NewsAction extends CommonAction
{
	public function articleList() {
		$Model = M('article_news');
	
		$this -> _list( $Model, '', true );
	
		$this -> display();
	}
	
	/**
	 * 扩展字段(non-PHPdoc)
	 * @see CommonAction::outputExt()
	 */
	protected function outputExt($list) {
		if ( $list ) {
			$articleList = $this -> getArticleCategorys('id, name');
			foreach ( $list as $key => $val ) {
				if ( isset($val['create_time']) )
					$val['create_time'] = date('Y-m-d H:i:s', $val['create_time']);
				if ( isset($val['update_time']) )
					$val['update_time'] = date('Y-m-d H:i:s', $val['update_time']);
				if ( isset($val['title']) ){
					if (utf8_strlen($val['title']) > 20)
						$val['title'] = utf8_substr($val['title'], 0, 20).'......';
				}
				if ( isset($val['category_id']) )
					$val['category_id'] = $articleList[$val['category_id']]['name'];
					
				$list[$key] = $val;
			}
		}
	
		return $list;
	}
}